#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include<vector>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> arr(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> arr[i];
    }
    vector<long long> dp(n + 1);
    for (int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1] + arr[i];
    }
    int i = 0;
    int r = 0;
    while (q--)
    {
        cin >> i >> r;
        cout << dp[r] - dp[i - 1] << endl;
    }
    return 0;
}
